package lab2;

import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;

import lab2.MyMap.Entry;

public class Application {

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void main(String[] args) {
		
		/*Integer[] inputArray = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
		Integer[] inputArray2 = {100, 101, 102, 103};
		
		
		MyLinkedList mll = new MyLinkedList<Integer>();
		MyLinkedList<Integer> mll2 = new MyLinkedList<Integer>();
				
		mll.addAll(inputArray);
		System.out.println(mll.toString());
		
		mll.add(10);
		System.out.println(mll.toString());
		
		mll.add(0, 10);
		System.out.println(mll.toString());
		
		//mll.add(-2, 15);
		//System.out.println(mll.toString());
		
		mll.set(5, 18);
		System.out.println(mll.toString());
		
		mll2.addAll(inputArray2);
		mll = new MyLinkedList(mll2);
		System.out.println(mll.toString());
		
		mll.clear();
		mll.addAll(inputArray);
		mll.addAll(3, inputArray2);
		System.out.println(mll.toString());
		
		mll.removeFirst();
		mll.removeLast();
		mll.add(5, 18);
		mll.remove(10);
		System.out.println(mll.toString());
		
		Iterator desc = mll.descendingIterator();
		while (desc.hasNext())
			System.out.print(desc.next().toString() + "; ");
		System.out.println(desc.next());
		
		mll.push(200);
		mll.offer(300);
		mll.peek();
		mll.pop();
		mll.poll();
		System.out.println(mll.toString());
		
		MyCollections.sort(mll);
		System.out.println(mll.toString());
		
		System.out.println("////////");
		Comparator<Integer> r = Collections.reverseOrder();
		MyCollections.sort(mll, r);
		System.out.println(mll.toString());
		System.out.println("////////");
		
		mll.clear();
		mll.addAll(inputArray);
		mll.push(35);
		mll.push(38);
		mll.pop();
		mll.offer(306);
		mll.poll();
		mll.poll();
		mll.push(11);
		System.out.println(mll.toString());*/
		
		
		
		/*MyArrayList<Integer> mal = new MyArrayList<Integer>();
		MyArrayList<Integer> mal2 = new MyArrayList<Integer>();
		
		//mal.remove(1);
		
		mal.addAll(inputArray);
		System.out.println(mal.toString());
		
		mal.add(10);
		System.out.println(mal.toString());
		
		mal.add(0, 10);
		System.out.println(mal.toString());
		
		//mal.add(-2, 15);
		//System.out.println(mal.toString());
		
		mal.set(5, 18);
		System.out.println(mal.toString());
		
		mal2.addAll(inputArray2);
		System.out.println(mal2.toString());
		mal = new MyArrayList(mal2);
		System.out.println(mal.toString());
		
		mal.clear();
		mal.addAll(inputArray);
		mal.addAll(3, inputArray2);
		System.out.println(mal.toString());
		
		mal.remove(5);
		mal.remove(1);
		mal.remove(mal.size());
		System.out.println(mal.toString());
		
		mal.trimToSize();
		System.out.println(mal.toString());
		
		mal.clear();
		mal.addAll(inputArray);
		mal.clear();
		mal.addAll(inputArray);
		mal.addAll(3, inputArray2);
		mal.remove(0);
		mal.add(5, 18);
		mal.remove(10);
		System.out.println(mal.toString());
		
		mal.clear();
		mal.addAll(inputArray);
		mal.addAll(inputArray2);
		System.out.println(mal.toString());
		
		Iterator iter = mal.iterator();
		Object o;
		String res = "";
		while (iter.hasNext()) {
			if ((o = iter.next()) != null) {
				res += o.toString() + "; ";
			} else {
				res += "null; ";
			}
		}
		System.out.println(res);
		
		MyCollections.swap(mal, 0, mal.size() - 1);
		System.out.println(mal.toString());
		
		mal.clear();
		mal.addAll(inputArray);
		mal.addAll(3, inputArray2);
		//mal.trimToSize();
		System.out.println(mal.toString() + " --- " + mal.size());
		
		MyCollections.sort(mal);
		System.out.println(mal.toString());
		
		System.out.println("////////");
		Comparator<Integer> r = Collections.reverseOrder();
		MyCollections.sort(mal, r);
		System.out.println(mal.toString());
		System.out.println("////////");
		
		MyLinkedList<Integer> mll3 = new MyLinkedList<Integer>();
		mll3.addAll(inputArray);
		MyCollections.copy(mal, mll3);
		System.out.println(mal.toString());
		
		MyCollections.sort(mal);
		System.out.println(mal.toString());
		MyCollections.reverse(mal);
		System.out.println(mal.toString());
		
		//System.out.println(MyCollections.binarySearch(mal, 9));
		
		mal.clear();
		mal.addAll(inputArray);
		mll3.clear();
		mll3.addAll(inputArray2);
		MyCollections.copy(mal, mll3);
		System.out.println(mal.toString());
		
		mal.clear();
		mal.addAll(inputArray);
		mal.addAll(inputArray2);
		MyCollections.reverse(mal);
		System.out.println(mal.toString());
		
		mal.clear();
		mal.addAll(inputArray);
		mal.trimToSize();
		System.out.println(mal.toString());
		System.out.println(MyCollections.binarySearch(mal, 4));
		
		mal.clear();
		mal.addAll(inputArray);
		mal.addAll(3,inputArray2);
		MyCollections.sort(mal);
		System.out.println(mal.toString());
				
		System.out.println(MyCollections.binarySearch(mal, 150));*/
		
		
		/*MyHashMap<Integer, String> mhm = new MyHashMap<Integer, String>();
		mhm.put(1, "Hello");
		mhm.put(2, "World");
		mhm.put(5, "Lapa");
		mhm.put(15, "Preved");
		System.out.println(mhm.toString());
		
		mhm.put(10, "ku-ku");
		mhm.put(19, "ku-ku-ku");
		System.out.println(mhm.toString());
		
		System.out.println(mhm.get(2));
		System.out.println(mhm.get(19));
		System.out.println();
		
		mhm.put(19, "ko-ko-ko");
		System.out.println(mhm.toString());
		mhm.put(32, "ko-ko-ko");
		System.out.println(mhm.toString());
		
		MyHashMap<Integer, String> mhm2 = new MyHashMap<Integer, String>(2);
		mhm2.put(2, "Hello");
		System.out.println(mhm2.toString());
		mhm2.put(19, "World");
		System.out.println(mhm2.toString());
		mhm2.put(32, "!");
		System.out.println(mhm2.toString());
		
		MyHashMap<Integer, String> mhm3 = new MyHashMap<Integer, String>(4);
		mhm3.put(1, "Hello");
		mhm3.put(2, "World");
		mhm3.put(3, "!");
		mhm3.put(4, "!!!");
		Iterator iter = mhm3.entryIterator();
		Entry o;
		String res = "";
		while (iter.hasNext()) {
			if ((o = (Entry) iter.next()) != null) {
				res += o.getKey() + " - " + o.getValue() + "; ";
			} else {
				res += "null; ";
			}
		}
		System.out.println(res);*/
		
		/*
		MyTreeMap<Integer, String> mtm = new MyTreeMap<Integer, String>();
		mtm.put(10, "Hello");
		mtm.put(20, "World");
		mtm.put(8, "aaaa");
		mtm.put(9, "zzz");
		//mtm.put(4, "!!!!");
		//mtm.put(19, "%%%");
		//mtm.put(25, "ooo");
		//mtm.put(15, "ooo");
		//mtm.put(14, "lylyly");
		//mtm.put(22, "gggg");		
		//mtm.put(23, "yyyyy");
		System.out.println(mtm.toString());		
		//mtm.remove(4);
		//mtm.remove(9);
		//System.out.println(mtm.toString());
		//mtm.remove(10);
		System.out.println(mtm.toString());
		*/
		
		/*
		Iterator iter = mtm.entryIterator();
		Object o;
		String res = "";
		while (iter.hasNext()) {
			if ((o = iter.next()) != null) {
				res += o.toString() + "; ";
			} else {
				res += "null; ";
			}
		}
		System.out.println(res);
		*/
		
		/*
		mtm.clear();
		mtm.put(10, "Hello");
		mtm.put(20, "World");
		mtm.put(8, "aaaa");
		mtm.put(9, "zzz");
		System.out.println(mtm.toString());
		mtm.remove(9);
		System.out.println(mtm.toString());
		mtm.put(9, "gggg");
		System.out.println(mtm.toString());
		
		Iterator iter2 = mtm.entryIterator();
		Object o2;
		String res2 = "";
		while (iter2.hasNext()) {
			if ((o2 = iter2.next()) != null) {
				res2 += o2.toString() + "; ";
			} else {
				res2 += "null; ";
			}
		}
		System.out.println(res2);
		System.out.println(mtm.containsKey(9));
		*/
		
		/*
		Comparator<Integer> r = Collections.reverseOrder();
		MyTreeMap<Integer, String> mtm2 = new MyTreeMap<Integer, String>(r);
		mtm2.put(10, "Hello");
		mtm2.put(20, "World");
		mtm2.put(8, "aaaa");
		mtm2.put(9, "zzz");
		mtm2.put(4, "!!!!");
		mtm2.put(19, "%%%");
		mtm2.put(25, "ooo");
		mtm2.put(15, "ooo");
		mtm2.put(14, "lylyly");
		System.out.println(mtm2.toString());
		*/
	}
}
